from launch import LaunchDescription
from launch_ros.actions import Node
import os
from ament_index_python.packages import get_package_share_directory

def generate_launch_description():
    bringup_dir = get_package_share_directory('nav2_bringup')
    map_file = os.path.join(bringup_dir, 'maps', 'turtlebot3_world.yaml')

    return LaunchDescription([
        Node(
            package='nav2_map_server',
            executable='map_server',
            name='map_server',
            output='screen',
            parameters=[{'yaml_filename': map_file}],
            remappings=[
                ('/map', '/map'),  # 这里确保将/map主题映射到/map
                ('/map_server/transition_event', '/map_server/transition_event')
            ]
        ),
    ])
